#!/usr/bin/env bash

filepath='/home/avanti/Downloads/下载中/file-list.txt'
echo "已保存视频列表" >"$filepath"
# if [ ! -f "$filepath" ]; then
#     echo "已保存视频列表" >"$filepath"
# fi

str=$(df -hl | grep media)
path=${str#*'% '}

for file in $(ls "$path"); do
    echo "$file"
    if [ -d "$path/$file" ]; then #注意此处之间一定要加上空格，否则会报错
        echo "$file" >>"$filepath"
        ls "$path/$file" >>"$filepath"
    fi
done
